<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="viewport" content="height=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <title></title>
    <link  href="loanStatic/css/common.css"
    	th:href="@{/loanStatic/css/common.css?v=3.3.6}" rel="stylesheet">
   	<link  href="loanStatic/css/register.css"
   	th:href="@{/loanStatic/css/register.css?v=3.3.6}" rel="stylesheet">
   	<link th:href="@{/loanStatic/tip/mdialog.css}" rel="stylesheet" type="text/css">
    <script th:src="@{/loanStatic/tip/mdialog.js}"></script>
    <script th:src="@{/loanStatic/js/fromSumbit/jquery.min.js}" type="text/javascript"></script>
    <style>
        .message{
            background: none;
            padding-top: 10%;
        }
        .message input {
            width: 83%;
            margin: 0 4%;
        }
        .content input:not(:nth-child(6)) {
            border: 0;
            margin-bottom: 8%;
        }
        .message .icons b{
            top: 14.5%;
            left: 11%;
        }
        .message .icons b:nth-child(2){
            top: 37%;
            left: 10%;
        }
        .message .icons b:nth-child(3){
            top: 60%;
        }
        .message .icons b:nth-child(4){
            top: 82%;
        }
        .code{
            top: 33.475%;
            right: 7.5%;
            background: #21a9f5;
            color: #ffffff;
            padding: 3.635% 5%;
        }
    </style>
</head>
<body>
    <div class="register">
        <div class="regTop">
            <span>忘记密码</span>
            <a class="back" th:href="@{/moblie/login}">&lt;&nbsp;返回</a>
        </div>
        <div class="content">
           <div class="message">
               <input type="tel" id="mobile" maxlength="11" placeholder="输入手机号" onkeyup="this.value=this.value.replace(/\D/g,'')"/>
               <input type="text" id="code" placeholder="输入验证码" onkeyup="this.value=this.value.replace(/\D/g,'')"  maxlength="6" disabled="disabled"/>
               <input type="password" id="passwordOne" placeholder="请输入新密码" />
               <input type="password" id="passwordTwo" placeholder="请再次输入密码" />
               <div class="icons">
                   <b><img th:src="@{/loanStatic/images/zc-1.jpg}" alt=""/></b>
                   <b><img th:src="@{/loanStatic/images/zc-2.jpg}" alt=""/></b>
                   <b><img th:src="@{/loanStatic/images/zc-3.jpg}" alt=""/></b>
                   <b><img th:src="@{/loanStatic/images/zc-3.jpg}" alt=""/></b>
               </div>
               <a class="code" id="getCode" onclick="getModifyCodeBtn();" >获取验证码</a>
           </div>
           <button class="submit" type="submit" onclick="modifyMobileBtn();">确认修改</button>
        </div>
    </div>
     <script>
    var checkMarkRequesting = false;
	var regex = /^(((1[3456789][0-9]{1})|(15[0-9]{1}))+\d{8})$/;
	var counterInterval;
	var count = 60;
	
	//注册按钮
    function modifyMobileBtn(){
    	var mobile = $("#mobile").val();
    	var code = $("#code").val();
    	var passwordOne = $("#passwordOne").val();
    	var passwordTwo = $("#passwordTwo").val();
    	if("" == mobile|| mobile==null){
			new TipBox({type:'tip',str:'手机号码不能为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		if (!regex.test(mobile)) {
			new TipBox({type:'tip',str:'手机格式不正确',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		if("" == code|| code==null){
			new TipBox({type:'tip',str:'验证码不能为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		if("" == passwordOne|| passwordOne==null){
			new TipBox({type:'tip',str:'密码不能为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		if("" == passwordTwo|| passwordTwo==null){
			new TipBox({type:'tip',str:'二次密码不为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		if(passwordOne!=passwordTwo){
			new TipBox({type:'tip',str:'两次密码不一致',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		$.ajax({
			url : "/moblie/modifyPasswordBtn",
			data : {"mobile": mobile,"password":passwordTwo,"code":code},
			dataType : "json",
			type : 'post',
			success : function(data) {
				if (data=='200') {
					new TipBox({type:'success',str:'修改成功！',clickDomCancel:true,setTime:1000,hasBtn:false});
					setTimeout("window.location.href='/moblie/login'",1300)
				}else if(data=='202'){
					new TipBox({type:'error',str:'发送失败！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='203'){
					new TipBox({type:'tip',str:'手机号不存在！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='204'){
					new TipBox({type:'tip',str:'验证码已过期！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='205'){
					new TipBox({type:'tip',str:'验证码不正确！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}
			},
			error : function() {
				alert("网络异常，请稍后重试！");
			}
		});
		
		
		
    }
    //获取验证码
    function getModifyCodeBtn(){
    	if (checkMarkRequesting) {
			return;
		}
		var mobile = $("#mobile").val();
		if("" == mobile|| mobile==null){
			new TipBox({type:'tip',str:'手机号码不能为空',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		if (!regex.test(mobile)) {
			new TipBox({type:'tip',str:'手机号码不正确',clickDomCancel:true,setTime:1000,hasBtn:false}); 
    		return;
		}
		
		$.ajax({
			url : "/moblie/modifyMobileGetCode",
			data : {"mobile": mobile},
			dataType : "json",
			type : 'post',
			success : function(data) {
				if (data=='200') {
					new TipBox({type:'success',str:'发送成功！',clickDomCancel:true,setTime:1000,hasBtn:false});
					counterInterval = setInterval(function() {
						count--;
						if (count <= 0) {
							$("#getCode").html("获取验证码");
							clearInterval(counterInterval);
							checkMarkRequesting = false;
							count = 60;
							return;
						}
						$("#getCode").html(count + "秒后重试");
					}, 1000);
					checkMarkRequesting = true;
					$("#code").removeAttr("disabled");
				}else if(data=='202'){
					new TipBox({type:'error',str:'发送失败！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}else if(data=='203'){
					new TipBox({type:'tip',str:'手机号不存在！',clickDomCancel:true,setTime:1000,hasBtn:false});
				}
				
			},
			error : function() {
				alert("网络异常，请稍后重试！");
			}
		});
    }
    </script>
</body>
</html>